package com.ellecity06.cwhiskymall.http

import com.ellecity06.common.http.entity.ApiResponse
import com.ellecity06.cwhiskymall.bean.request.*
import com.ellecity06.cwhiskymall.bean.response.*
import com.ellecity06.cwhiskymall.storage.UserStorage
import okhttp3.ResponseBody
import retrofit2.Response
import retrofit2.http.*


/**
 * @author ellecity06
 * @time 2023/4/13 12:02
 * @des
 */
interface ApiService {

    @Streaming
    @GET
    suspend fun download(@Url url: String): Response<ResponseBody>

    /**
     * 查询最新版本信息
     */
    @POST("api/web/setting/getLastVersionInfo")
    suspend fun lastVersion(@Body request: VersionInfoRequest): ApiResponse<AppVersionResponse>

    /**
     * 获取短信验证码
     */
    @POST("api/web/auth/sms/sendCode")
    suspend fun smsCode(@Body request: SendSmsCodeRequest): ApiResponse<String>

    /**
     * 用户注销
     */
    @POST("api/web/auth/cancelMember")
    suspend fun cancelMember(): ApiResponse<String>

    /**
     * 注册
     */
    @POST("api/web/auth/register")
    suspend fun register(@Body request: RegisterRequest): ApiResponse<String>

    /**
     * 密码登录
     */
    @POST("api/web/auth/pwdLogin")
    suspend fun passwordLogin(@Body request: LoginRequest): ApiResponse<MemberInfo>

    /**
     * 验证码登录
     */
    @POST("api/web/auth/smsLogin")
    suspend fun smsCodeLogin(@Body request: LoginRequest): ApiResponse<MemberInfo>

    /**
     * 退出登录
     */
    @POST("api/web/auth/logout")
    suspend fun logout(): ApiResponse<String>

    /**
     * 获取APP菜单布局配置带缓存
     */
    @POST("api/web/setting/getAppMenuSetting")
    suspend fun appMenuSetting(@Body request: AppMenuSettingRequest): ApiResponse<AppMenuSettingRespone>

    /**
     * 查询专题商品列表
     */
    @POST("api/web/goods/selectSpecialGoodsPageList")
    suspend fun specialGoods(@Body request: GoodRequest): ApiResponse<BaseListResponse<GoodResponse>>

    /**
     * 查询专题商品列表
     */
    @POST("api/web/goods/getCagetoryList")
    suspend fun getCagetoryList(): ApiResponse<List<ClassifyResponse>>

    /**
     * 查询个人中心页面信息
     */
    @POST("api/web/member/getMemberCenterInfo")
    suspend fun userCenter(): ApiResponse<UserCenterResponse>

    /**
     * 查询个人账户信息
     */
    @POST("api/web/member/getMemberAccountInfo")
    suspend fun userAccountInfo(): ApiResponse<UserAccountResponse>

    /**
     * 查询个人信息
     */
    @POST("api/web/member/getMemberInfo")
    suspend fun userInfo(): ApiResponse<MemberInfo>

    /**
     * ossToken
     */
    @POST("api/web/aliOssUpload")
    suspend fun ossKey(): ApiResponse<OssKeyResponse>

    /**
     * 移动应用申请获取STS凭证
     */
    @POST("api/web/presignedUrl")
    suspend fun ossSts(): ApiResponse<OssStsResponse>

    /**
     * 修改个人信息
     */
    @POST("api/web/member/updateMemberInfo")
    suspend fun updateUser(@Body request: UpdateUserRequest): ApiResponse<String>


    /**
     * 查询商品列表
     */
    @POST("api/web/goods/categoryGoodsPageList")
    suspend fun getClassifyRightList(@Body request: ClassifyRightRequest): ApiResponse<ClassifyGoods>

    /**
    <<<<<<< HEAD
     * 消费赠送的领取记录
     */
    @POST("api/web/contribution/getRecordList")
    suspend fun contributionRecordList(): ApiResponse<ConsumerRecordResponse>

    /**
     * 首次去领取
     */
    @POST("api/web/contribution/firstReceiveContribution")
    suspend fun firstReceiveContribution(@Query("contriLevelId") contriLevelId: Int?): ApiResponse<FisrtReceiveResponse>

    /**
     * 叠加领取
     */
    @POST("api/web/contribution/superposeReceiveContribution")
    suspend fun superposeReceiveContribution(
        @Query("contriLevelId") contriLevelId: Int?,
        @Query("contributionLevel") contributionLevel: String?
    ): ApiResponse<FisrtReceiveResponse>
//    ==== 酒神专区消费领取贡献金
    /**
    <<<<<<< HEAD
     * 消费赠送的领取记录
     */
    @POST("api/web/contribution/getDionysusRecordList")
    suspend fun contributionRecordList9000(): ApiResponse<ConsumerRecordResponse>
    /**
     * 酒神专区首次去领取
     */
    @FormUrlEncoded
    @POST("api/web/contribution/firstReceiveDionysusContribution")
    suspend fun firstReceiveContribution9000(@Field("dionysusRecordId") dionysusRecordId: Int?): ApiResponse<FisrtReceiveResponse>

    /**
     * 叠加领取
     */
    @FormUrlEncoded
    @POST("api/web/contribution/superposeReceiveDionysusContribution")
    suspend fun superposeReceiveContribution9000(
        @Field("dionysusRecordId") dionysusRecordId: Int?,
        @Field("contributionLevel") contributionLevel: String?
    ): ApiResponse<FisrtReceiveResponse>

    @POST("api/web/auth/updateMemberPwd")
    suspend fun forgetPwd(@Body request: ForgetPwdRequest): ApiResponse<String>

    /**
     * 新增地址
     */
    @POST("api/web/memberAddr/add")
    suspend fun addressAdd(@Body request: AddressAddRequest): ApiResponse<String>

    /**
     * 获取地址列表
     */
    @POST("api/web/memberAddr/list")
    suspend fun addressList(): ApiResponse<List<AddressAddRequest>>

    /**
     * 设置默认地址
     */
    @POST("api/web/memberAddr/setfaultAddress")
    suspend fun setDefaultAddress(@Body request: AddressEditRequest): ApiResponse<String>

    /**
     * 删除地址
     */
    @POST("api/web/memberAddr/delete")
    suspend fun deleteAddress(@Body request: AddressEditRequest): ApiResponse<String>

    /**
     * 根据Id获取地址
     */
    @POST("api/web/memberAddr/getById")
    suspend fun fetchAddressById(@Body request: AddressEditRequest): ApiResponse<AddressAddRequest>

    /**
     * 修改地址
     */
    @POST("api/web/memberAddr/update")
    suspend fun addressEdit(@Body request: AddressAddRequest): ApiResponse<String>

    /**
     * 查询商品列表
     */
    @POST("api/web/goods/pageList")
    suspend fun goodList(@Body request: GoodRequest): ApiResponse<BaseListResponse<GoodResponse>>

    /**
     * 查询商品列表
     */
    @POST("api/web/goods/getGoodsDetail")
    suspend fun getGoodsDetail(@Body request: GoodRequest): ApiResponse<GoodDetailResponse>

    /**
     * 查询会员和邀请信息
     */
    @GET("api/web/member/findInvitedMemberInfo")
    suspend fun findInvitedMemberInfo(@Query("phone") phone: String): ApiResponse<MemberInviteResponse>

    /**
     * 查询会员邀请的列表信息 分页
     */
    @POST("api/web/member/findMemberInfo")
    suspend fun findMemberInfoList(@Body request: FindMemberInviteRequest): ApiResponse<BaseListResponse<MemberInviteResponse.Member>>

    /**
     * 获取H5的地址
     */
    @POST("api/web/setting/getH5RequestUrl")
    suspend fun getH5RequestUrl(@Body request: H5UrlRequest): ApiResponse<H5UrlResponse>

    /**
     * 解锁单剩余贡献值
     */
    @POST("api/web/newPeopleUnlock/surplusContribution")
    suspend fun surplusContribution(): ApiResponse<SurplusContributionResonse>

    /**
     * 领取首单解锁福利
     */
    @POST("api/web/newPeopleUnlock/receiveWelfare")
    suspend fun receiveWelfare(): ApiResponse<String>

    /**
     * 领取首单解锁福利
     */
    @GET("api/web/setting/getFirstUnlockState")
    suspend fun getFirstUnlockState(): ApiResponse<Int?>

    /**
     * 识别身份证信息
     * @param imageUrl    图片地址
     * @param side    face:正面，back:反面
     */
    @POST("api/web/member/realName/recognizeIdCard")
    suspend fun recognizeIdCard(
        @Query("imageUrl") imageUrl: String,
        @Query("side") side: String = "face"
    ): ApiResponse<RecognizeIdCardResponse>

    /**
     * 识别身份证信息
     * @param imageUrl    图片地址
     * @param side    face:正面，back:反面
     */
    @POST("api/web/member/realName/submit")
    suspend fun submitAuth(
        @Query("backUrl") backUrl: String,
        @Query("frontUrl") frontUrl: String,
        @Query("identifyNum") identifyNum: String,
        @Query("userName") userName: String
    ): ApiResponse<RecognizeIdCardResponse>

    /**
     * 获取文化数据登录Token
     */
    @POST("api/web/auth/getCultureToken")
    suspend fun getCultureToken(): ApiResponse<CultureTokenResponse?>

    /**
     * 获取资产统计数据
     */
    @GET("api/web/culture/assets/statistical")
    suspend fun statistical(): ApiResponse<StatisticalResponse>

    /**
     * 获取资产统计数据
     */
    @POST("api/web/setting/getBatchH5RequestUrl")
    suspend fun getBatchH5RequestUrl(@Body request: H5UrlRequest): ApiResponse<BeH5UrlResponse>

    /**
     * 获取资产统计数据
     */
    @POST("api/web/newPeopleTeach/list")
    suspend fun newPeopleTeachList(): ApiResponse<List<NewerLearningResponse>>

    /**
     * 搜索发现
     */
    @POST("api/web/searchDiscovery/getSearchDiscovery")
    suspend fun searchDiscovery(@Body request: SearchDiscoveryRequest): ApiResponse<SearchDiscoveryResponse>

    /**
     * 获取直播间列表
     */
    @POST("api/web/live/page")
    suspend fun liveRoomList(): ApiResponse<List<LiveRoomResponse>>
    /**
     * 获取直播间详情
     */
    @FormUrlEncoded
    @POST("api/web/live/status")
    suspend fun liveRoomDetail(@Field("pullId") pullId: String?): ApiResponse<LiveRoomResponse>

    /**
     * 进入直播间
     */
    @FormUrlEncoded
    @POST("api/web/live/enter")
    suspend fun enterLiveRoom(
        @Field("pullId") pullId: String?,
        @Field("userId") userId: Int? = UserStorage.user?.id
    ): ApiResponse<String?>

    /**
     * 退出直播间
     */
    @FormUrlEncoded
    @POST("api/web/live/exit")
    suspend fun exitLiveRoom(
        @Field("pullId") pullId: String?,
        @Field("userId") userId: Int? = UserStorage.user?.id
    ): ApiResponse<String?>

    /**
     * 获取直播间商品列表
     */
    @FormUrlEncoded
    @POST("api/web/live/goods")
    suspend fun liveRoomGoods(@Field("liveId") liveRoomId: Int): ApiResponse<List<LiveRoomGoodResponse>?>

    /**
     * 查询直播间在线人数
     */
    @FormUrlEncoded
    @POST("api/web/live/num")
    suspend fun liveRoomOnLineNum(@Field("pullId") pullId: String? ): ApiResponse<String?>

    /**
     * 进入直播间查询正在讲解的商品
     */
    @FormUrlEncoded
    @POST("api/web/live/popup")
    suspend fun liveRoomTopGood(@Field("liveId")  liveRoomId: Int ): ApiResponse<LiveRoomGoodResponse?>
    /*
     * 查询会员和邀请信息
     */
    @GET("api/web/setting/getOtherSetting")
    suspend fun getOtherSetting(@Query("code") code: String="direct_inviter_ratio"): ApiResponse<OtherSettingResponse>


}